screen_data 返回抗原结果

FFIB 2 anni fa
parent
commit
7b5bad15af
2 ha cambiato i file con 19 aggiunte e 6 eliminazioni
  1. 6 5
      api/eqpt_views.py
  2. 13 1
      equipment/models.py

+ 6 - 5
api/eqpt_views.py

@@ -170,6 +170,7 @@ def eqpt_result(request):
170 170
         'fever_num': fever_num,
171 171
     })
172 172
 
173
+
173 174
 def protect_user_privacy(field):
174 175
     if (field.get('key', '') == 'phone'):
175 176
         phone = list(field.get('value', ''))
@@ -182,6 +183,7 @@ def protect_user_privacy(field):
182 183
 
183 184
     return field.get('value', '')
184 185
 
186
+
185 187
 def get_screen_data(point=None, point_id=None):
186 188
     if not point:
187 189
         try:
@@ -200,7 +202,7 @@ def get_screen_data(point=None, point_id=None):
200 202
         ipuis = ipuis.exclude(last_submit_at__range=(start_dt, end_dt), temperature__gt=0.0, temperature__lte=settings.FEVER_TEMPERATURE)
201 203
 
202 204
         ipuis = [{**ipui.data, **{
203
-            field.get('key', ''): protect_user_privacy(field) for field in ipui.fields }} for ipui in ipuis]
205
+            field.get('key', ''): protect_user_privacy(field) for field in ipui.fields}} for ipui in ipuis]
204 206
         reminds = [{
205 207
             'name': ipui.get('name'),
206 208
             'room': ipui.get('room'),
@@ -220,7 +222,7 @@ def get_screen_data(point=None, point_id=None):
220 222
                 ipui['status'] = '未使用'
221 223
                 ipuis_unused.append(ipui)
222 224
                 continue
223
-                
225
+
224 226
             last_submit_at = tc.make_naive(last_submit_at)
225 227
 
226 228
             if (start_dt < last_submit_at < end_dt) and temperature > settings.FEVER_TEMPERATURE:
@@ -230,11 +232,11 @@ def get_screen_data(point=None, point_id=None):
230 232
                 ipui['temperature'] = '-'
231 233
                 ipui['status'] = '未测温'
232 234
                 ipuis_not_upload.append(ipui)
233
-            
235
+
234 236
         not_upload_temperature_num = len(ipuis_unused) + len(ipuis_not_upload)
235 237
         has_upload_temperature_num = total_active_eqpt_num - not_upload_temperature_num
236 238
         normal_num = has_upload_temperature_num - len(ipuis_fever)
237
-        
239
+
238 240
         return {
239 241
             'eqpts': ipuis_fever + ipuis_unused + ipuis_not_upload,
240 242
             'reminds': reminds,
@@ -246,7 +248,6 @@ def get_screen_data(point=None, point_id=None):
246 248
             'update_time': tc.local_string(),
247 249
         }
248 250
 
249
-    
250 251
     has_upload_temperature_num = len([1 for ipui in ipuis if ipui.get('temperature_has_upload', '') == IsolationPointUserInfo.HAS_YET_UPLOAD])
251 252
     fever_num = len([1 for ipui in ipuis if ipui.get('temperature', 0) > settings.FEVER_TEMPERATURE and ipui.get('temperature_has_upload') == IsolationPointUserInfo.HAS_YET_UPLOAD])
252 253
 

+ 13 - 1
equipment/models.py

@@ -6,6 +6,7 @@ from django_models_ext import BaseModelMixin, SexModelMixin
6 6
 from jsonfield import JSONField
7 7
 from shortuuidfield import ShortUUIDField
8 8
 from TimeConvert import TimeConvert as tc
9
+import datetime
9 10
 
10 11
 from utils.redis.rqrurl import get_qrcode_url
11 12
 
@@ -184,6 +185,17 @@ class IsolationPointUserInfo(BaseModelMixin):
184 185
         return IsolationPointUserInfo.HAS_NOT_CONNECTED
185 186
 
186 187
     @property
188
+    def get_antigen_result(self):
189
+        today = datetime.date.today()
190
+        if not self.detect_at:
191
+            return '-'
192
+
193
+        if today.day == self.detect_at.day and today.month == self.detect_at.month and today.year == self.detect_at.year:
194
+            return '-' if self.antigen_result == 2 else self.get_antigen_result_display()
195
+        else:
196
+            return '-'
197
+
198
+    @property
187 199
     def data(self):
188 200
         return {
189 201
             'pk': self.pk,
@@ -197,7 +209,7 @@ class IsolationPointUserInfo(BaseModelMixin):
197 209
             'last_submit_at': self.last_submit_at,
198 210
             'last_report_time': tc.local_string(utc_dt=self.last_submit_at, format='%m-%d %H:%M') if self.last_submit_at else '',
199 211
             'remark': self.remark or '',
200
-            'antigen_result': self.get_antigen_result_display(),
212
+            'antigen_result': self.get_antigen_result,
201 213
             'detect_at': tc.local_string(utc_dt=self.detect_at, format='%m-%d %H:%M') if self.detect_at else '',
202 214
         }
203 215